//
//  SharePhotosController.m
//  Xpress
//
//  Created by Leon on 15/1/28.
//  Copyright (c) 2015年 iOS team. All rights reserved.
//

#import "SharePhotosController.h"

@interface SharePhotosController ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property (nonatomic, retain)UICollectionView *photosCollection;


@end

@implementation SharePhotosController
- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}

- (void)dealloc
{
    [_photosCollection release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self creatCollectionView];
    
    
    
}

- (void)creatCollectionView
{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    // 设置item大小
    layout.itemSize = CGSizeMake(172, 172);
    // 设置最小item间最小间距
    layout.minimumInteritemSpacing = 1;
    layout.minimumLineSpacing = 10;
    // 设置item距离屏幕上中下右距离
    layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
    layout.headerReferenceSize = CGSizeMake(375, 60);
    
    
    // 创建CollectionView
    self.photosCollection = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:layout];
    self.photosCollection.delegate = self;
    self.photosCollection.dataSource = self;
    self.photosCollection.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.photosCollection];
    
    // 重用池
    [self.photosCollection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    
    
    [layout release];
    [_photosCollection release];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 2;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    
    cell.backgroundColor = [UIColor redColor];
    return cell;
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
